#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using LL=long long;
int main() {

	int n,x;
	cin>>n>>x;
	vector<int> vecArr(n+1);
	for(int i=1;i<=n;++i){
		cin>>vecArr[i];
	}
	sort(vecArr.begin()+1,vecArr.end());
	int nIdx=max(0,n-x);
	LL nRet=vecArr[nIdx]*x;
	for(int i=nIdx+1;i<=n;++i){
		nRet+=vecArr[i]-vecArr[nIdx];
	}
	cout<<nRet<<endl;
	
	return 0;
}
